#

| Chapter 35 You Can't Quite Call This Editing |

## 35.18 Pasting Things in Columns

cut+paste | Do you ever wish you could paste two (or even three) files side by side? You can, if you have the System V paste program (or the public-domain implementation on the disc).

For example, to create a three-column file from files x, y, and z:

>     $ paste x y z > file

To make paste read standard input, use the - option, and repeat `-` for every column you want. For example, to make an old broken System V ls (which lists files in a single column) list files in four columns:

>     $ ls | paste - - - -

The "standard input" option is also handy when used with cut (35.14). You can cut data from one position on a line and paste it back on another.

The separate data streams being merged are separated by default with a tab, but you can change this with the -d option. Unlike the -d option to cut, you need not specify a single character; instead, you can specify a list of characters, which will be used in a circular fashion. (I haven't figured a use for this - maybe you can.)

The characters in the list can be any regular character or the following escape sequences:

`\n`

  newline

`\t`

  tab

`\\`

  backslash

`\0`

  empty string

Use quoting (8.14), if necessary, to protect characters from the shell.

There's also a -s option that lets you merge subsequent lines from one file. For example, to merge each pair of lines onto a single line:

>     $ paste -s -d"\t\n" list

- TOR, DG

35.17 Making Text in Columns with pr |  | 35.19 Joining Lines with join